package com.zhentao.controller;

import com.zhentao.interfaceclass.LogInterface;
import com.zhentao.model.admin.page.RolePageParam;
import com.zhentao.model.admin.param.SysRoleMenuAddParam;
import com.zhentao.model.admin.rbac.SysRole;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.SysRoleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AdminRoleController
 * @Author: 振涛教育_Q
 * @Date: 2024/12/31 16:30
 */
@RestController
@RequestMapping("user/info")
public class AdminRoleController {
    @Autowired
    private SysRoleService roleService;


    /**
     * @description  查询角色列表
     * @author 振涛教育_小Q
     * @date    2024/12/31 16:30
      * @param
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @PostMapping("/role/list")
    public ResponseResult roleList(@RequestBody RolePageParam param){
        return roleService.roleList(param);
    }

    /**
     * @description  修改角色的基本信息
     * @author 振涛教育_小Q
     * @date    2025/1/1 17:08
      * @param sysRole
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @PostMapping("/role/add")
    @LogInterface(value = "管理端--修改角色")
    public ResponseResult editRole(@RequestBody SysRole sysRole){
        return roleService.editRole(sysRole);
    }

    /**
     * @description    对角色进行授权
     * @author 振涛教育_小Q
     * @date    2025/1/1 17:46
      * @param param
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @PostMapping("/role/menu/add")
    @LogInterface(value = "管理端--对角色进行授权")
    public ResponseResult roleMenuAdd(@RequestBody SysRoleMenuAddParam param){
        return roleService.roleMenuAdd(param);
    }

    /**
     * @description  软删除角色
     * @author 振涛教育_小Q
     * @date    2025/1/1 19:10
      * @param id
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @GetMapping("/role/delete/{id}")
    @LogInterface(value = "管理端--删除角色")
    public ResponseResult deleteRole(@PathVariable(value = "id") String id){
        return roleService.deleteRole(id);
    }
}
